/*
 * Virtual class for scenes. A scene consists of the following:
 * - Some objects, typically including at least one heightmap since this is a heightmap tracer.
 * - Some sort of heightmap surface reconstruction convention.
 * - An algorithm and any supporting data structures for ray tracing.
 * z is upwards.
 */

#pragma once

#include "Ray.h"
#include "RayColumn.h"
#include "SlopeRayColumn.h"
#include "Color3f.h"
#include "Intersection.h"
#include "Heightmap.h"
#include "Light.h"

class Scene {
public:
    //Readies this scene for ray tracing.
    virtual void ready() = 0;

    //Assigns a heightmap to this scene.
    virtual void assignHeightmap(Heightmap& heightmap) = 0;

    //Assigns a user-controlled light.
    virtual void assignUserLight(Light* light) = 0;

    //Modify the user light.
    virtual void modifyUserLight(float x, float y) = 0;

    //Traces a ray into the scene. Returns the color.
    virtual Color3f traceRay(Ray& ray) const = 0;

    //Traces a ray column into the scene. Default iterates over all rays in the column.
    virtual void traceRayColumn(Color3f* results, RayColumn& rayColumn) const {
        for (int i = 0; i < rayColumn.numRays; i++) {
            Ray ray(rayColumn.origin, rayColumn.dirs[i]);
            results[i] = traceRay(ray);
        }
    }

    //Traces a SlopeRayColumn into the scene. Default iterates over all rays in the column.
    virtual void traceSlopeRayColumn(Color3f* results, SlopeRayColumn& slopeRayColumn) const {
        for (int i = 0; i < slopeRayColumn.numRays; i++) {
            results[i] = traceRay(slopeRayColumn.getRay(i));
        }
    }

    //Traces a shadow ray. Returns true iff there is a collision.
    virtual bool traceShadowRay(Ray& ray) const = 0;
};
